package com.ys.controller;

import com.ys.common.R;
import com.ys.pojo.TradeCoupon;
import com.ys.service.CouponService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/coupon")
public class CouponController {
    @Autowired
    private CouponService couponService;
    @RequestMapping("/findCouponById/{couponId}")
    public R findCouponById(@PathVariable("couponId") Long couponId){

        return R.ok().data("coupon",couponService.findCouponById(couponId));
    }


    @RequestMapping("/changeCoponStatus")
    public R changeCoponStatus(@RequestBody TradeCoupon coupon){
        Boolean aBoolean = couponService.changeCoponStatus(coupon);

        return R.ok().success(aBoolean);
    }
}
